<?php
$name    = $_POST['name'];
$content = $_POST['content'];
$state   = $_POST['state'];
$ctime   = time();
@mysql_connect('localhost', 'root', 'root');
mysql_select_db('blog');
mysql_set_charset('utf8');
$sql = "insert into `lanmu` (`name`,`content`,`ctime`,`state`) values ('$name','$content','$ctime','$state')";
$res = mysql_query($sql);

if ($res) {
    echo "<script>alert('添加成功');window.location.href='index.php'</script>";
} else {
    echo "<script>alert('添加失败');window.location.href='add.php'</script>";
}
